package com.tbit.main.service.impl;

import com.tbit.main.constant.DaoParamConstant;
import com.tbit.main.dao.log.MainControlLogDao;
import com.tbit.main.pojo.MainControlLog;
import com.tbit.main.service.MainControlLogService;
import com.tbit.main.util.DateTimeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 控制指令日志
 *
 * @author Leon
 * 2019年11月22日 下午11:08:13
 */
@Service("mainControlLogService")
public class MainControlLogServiceImpl implements MainControlLogService {
    @Autowired
    private MainControlLogDao mainControlLogDao;

    @Override
    public void insert(MainControlLog mainControlLog) {
        mainControlLog.setOperaTime(DateTimeUtil.getNowTime());
        mainControlLogDao.insert(mainControlLog);
    }

    @Override
    public List<MainControlLog> queryPage(Integer accountId, Integer userMainId, String userCode, String startTime, String endTime, Integer rowCount, Integer pageNO) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put(DaoParamConstant.accountId, accountId);
        params.put("userMainId", userMainId);
        params.put("userCode", userCode);
        params.put(DaoParamConstant.startTime, startTime);
        params.put(DaoParamConstant.endTime, endTime);
        params.put("start", (pageNO - 1) * rowCount);
        params.put("rowCount", rowCount);

        return mainControlLogDao.queryPage(params);
    }

    @Override
    public Integer queryCount(Integer accountId, Integer userMainId, String userCode, String startTime, String endTime) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put(DaoParamConstant.accountId, accountId);
        params.put("userMainId", userMainId);
        params.put("userCode", userCode);
        params.put(DaoParamConstant.startTime, startTime);
        params.put(DaoParamConstant.endTime, endTime);

        return mainControlLogDao.queryCount(params);
    }


}
